package thread;

/**
 * 获取线程信息的相关方法
 */
public class ThreadInfoDmeo {
    public static void main(String[] args) {
        //获取主线程
        Thread main = Thread.currentThread();
        //获取线程名字
        String name = main.getName();
        System.out.println(name);
        //获取唯一标识
        long id = main.getId();
        System.out.println("唯一标识"+id);
        //获取线程优先级，默认是5
        int priority = main.getPriority();
        System.out.println("优先级："+priority);
        //判断线程时候活着
        boolean isAlive = main.isAlive();
        System.out.println("是否活着"+isAlive);
        System.out.println("是否为守护线程"+main.isDaemon());
        System.out.println("是否被中断了"+main.isInterrupted());
    }
}
